package com.isunland.managesystem.ui;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.ImageLoader.ImageListener;
import com.isunland.managesystem.R;
import com.isunland.managesystem.common.RequestManager;
import com.isunland.managesystem.utils.LogUtil;
import com.isunland.managesystem.widget.GestureImageView;

public class ImageFragment extends Fragment {
  public static final String EXTRA_IMAGE_URL = "com.isunland.managesystem.Fragment.IMAGE_RUL";
  private static final String TAG = "ImageFragment";

  @Override public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
  }

  @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,
      Bundle savedInstanceState) {

    View v = inflater.inflate(R.layout.fragment_image, container, false);
    GestureImageView iv = (GestureImageView) v.findViewById(R.id.iv_gesture);
    //iv.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    //iv.setStartingScale(2.0f);
    //		iv.setScaleType(ScaleType.CENTER_CROP);
    String url = getActivity().getIntent().getStringExtra(EXTRA_IMAGE_URL);
    LogUtil.i(TAG, "image cache url=" + url);

    ImageLoader imageLoader = RequestManager.getImageLoader();

    ImageListener listener =
        ImageLoader.getImageListener(iv, R.drawable.progress_round, R.drawable.fail_image);
    imageLoader.get(url, listener);
    return v;
  }
}
